<?php
 
   $lot=$_GET["lot"];
   $dbName = "sqlsrv:Server=172.31.3.9,1433;Database=emc3030";   //这里是服务器IP地址和数据库名，端口不是默认的话记得改一下
   $dbUser = "sa";    //用户名
   $dbPassword = "TDled2017";    //登陆密码
   $db = new PDO($dbName, $dbUser, $dbPassword);   
	$sql = "select id  from sl_bag where  ctype='1' and clotno='".$lot."'";//17620T4003-7250613 菲利浦
	
	$res = $db->query($sql)->fetchAll(PDO::FETCH_ASSOC);;
	//echo count($res);
	if (count($res)==0){
		//echo "row_count==0";
		$dbName_2 = "sqlsrv:Server=172.31.3.9,1433;Database=UFDATA_001_2017";   //这里是服务器IP地址和数据库名，端口不是默认的话记得改一下
		$db_2 = new PDO($dbName_2, $dbUser, $dbPassword);   
		$sql = "select clotno from ldx_seoulInsideMX where InsideboxNO = '".$lot."'";//18119T400R-7250715 菲利浦
		$res = null;
		$res = $db_2->query($sql);
		$rdisk="";
		$row = null;
		while ($row = $res->fetch()){
		  $rdisk.= $row['clotno'].",";
		}		
	} else {
		//echo "row_count<>0";
		$bid="";
		//print_r($res);
		$res= $db->query($sql);
		 while ($row = $res->fetch()){
		  $bid=$row['id'];
		 }
		$res = null;
		$sql = "select clotno  from sl_bags where  id= '".$bid."'";//17620T4003-7250613
		$res2 = $db->query($sql);
		$rdisk="";
		$row = null;
		 while ($row = $res2->fetch()){
		  $rdisk.= $row['clotno'].",";
		 }
	}
	 print_r($rdisk); 
	$res2 = null;
	$db = null;
